;define(function (require) {
	'use strict';
	var $=require('jquery');
		require('plugin/superslide');
	var config = require('config');
	var $Fun = require('functions');
	
	var app = {};
	//初始化
	app.init = function(){
		//十六进制转rgba
		String.prototype.color2Rgba=function(){var sColor=this.toLowerCase(),reg=/^#([0-9a-fA-f]{3}|[0-9a-fA-f]{6})$/;if(sColor&&reg.test(sColor)){if(sColor.length===4){var sColorNew="#";for(var i=1;i<4;i+=1){sColorNew+=sColor.slice(i,i+1).concat(sColor.slice(i,i+1))}sColor=sColorNew}var sColorChange=[];for(var i=1;i<7;i+=2){sColorChange.push(parseInt("0x"+sColor.slice(i,i+2)))}return"RGBA("+sColorChange.join(",")+","}else{return sColor}};
		
//		logs.log('loaded.');

		var _nav=require('plugin/nav');
		var nav=new _nav('#navbox','#navpoint');
		nav.run();
		
		//导航菜单
		$('#navbox li.menu').click(function(e){
			var el = window.event.srcElement || e.target;
			if(el.nodeName=="LI"){
				if($(this).find('a').length>0 && $(this).find('a').attr('href').indexOf('javascript')<0 ){
					location.href = $(this).find('a').attr('href'); 
				}
			}
		})
		
		
		var rwtpl='<div class="report-warper">\
				<div class="timeline">\
					<div class="year-label transition clearfix">\
						<span class="point"><span></span></span>\
						<b class="label-cont">{{year}}年专报</b>\
					</div>\
				</div>\
				<ul id="rp-{{year}}" class="reports-preview-warper">\
					\
				</ul>\
			</div>';
		var rcpl='<li id="pv-{{year}}-{{month}}" class="report-preview disvisible">\
						<div class="preview-cont"></div>\
						<div class="preview-note">\
							<div class="note-header">\
								<span class="note-title">{{year}}-{{month}}宏观经济专报</span>\
								<span class="note-btn">\
									<i class="preview-btn fa fa-eye"></i>\
									<i class="edit-btn fa fa-edit"></i>\
								</span>\
							</div>\
							<div class="note-cont">\
								<!-- 说明文字 -->\
							</div>\
						</div>\
					</li>';
		var html='';
		for(var i=2015;i>=2013;i--){
			html+=rwtpl.replace(/\{\{year\}\}/g,i);
		}
		$('.report-list').html(html);
		for(var y=2015;y>=2013;y--){
			var html='',m=12,l=1;
			for(;m>=l;m--){
				html+=rcpl.replace(/\{\{year\}\}/g,y).replace(/\{\{month\}\}/g,m);
			}
			$('#rp-'+y).html(html);
		}
		var i=0;
		for(var y=2015;y>=2013;y--){
			var html='',m=12,l=1;
			for(;m>=l;m--){
				addAnimateByTime('#pv-'+y+'-'+m,'rotateInUpLeft',(i++)*300+500);
			}
		}

		function addAnimateByTime(target,cls,time){
			setTimeout(function(){
				addAnimate(target,cls,null);
			},time);
		}
		function addAnimate(target,cls,callback){
			$(target).removeClass('disvisible').addClass('animated '+cls).one('webkitAnimationEnd mozAnimationEnd MSAnimationEnd oanimationend animationend', function(){
					$(this).removeClass('animated '+cls);
					if(typeof callback=='function'){
						callback();
					}
				});
		}
	};
	return app;
});